<%--
    Document   : newjsp
    Created on : 2012-3-2, 20:38:44
    Author     : wl
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib  prefix="s"  uri="/struts-tags"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>注册</title>
        <link href="css/global.css" rel="stylesheet" type="text/css">
        <link href="css/form.css" rel="stylesheet" type="text/css">
        <style type="text/css">
            div.header
            {
                font-family: 微软雅黑;
                font-size: 14px;
                padding:20px;
                color:white;
                background-color:#7B994F;
                text-align: center;
                height: 70px;
                width: 250px;
                margin-left: 400px;
                margin-top: 50px;
            }
        </style>
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/jquery.validate.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#signup').validate({
                    rules: {
                        'register.username': {
                            required: true,
                            rangelength:[4,16]
                        },
                        'register.email': {
                            required: true,
                            email: true
                        },
                        'register.password': {
                            required: true,
                            rangelength:[5,16]
                        },
                        'confirm_password': {equalTo:'#password'},
                        spam: "required"
                    }, //end rules
                    messages: {
                        'register.username': {
                            required: '请输入用户名',
                            rangelength: '用户名在 4 到 16 位之间'
                        },
                        'register.email': {
                            required: "请输入邮箱地址",
                            email: "不是有效的邮箱地址"
                        },
                        'register.password': {
                            required: '请输入密码',
                            rangelength: '密码在 5 到 16 位之间'
                        },
                        'confirm_password': {
                            equalTo: '2次密码不一致'
                        }
                    },
                    errorPlacement: function(error, element) {
                        if ( element.is(":radio") || element.is(":checkbox")) {
                            error.appendTo( element.parent());
                        } else {
                            error.insertAfter(element);
                        }
                    }

                }); // end validate
            }); // end ready()
        </script>
    </head>
    <body>
        <s:if test="%{#session.islogin}">
            <div class="header">
                欢迎您，<s:property value="%{#session.username}"></s:property>，您已登陆
            </div>
        </s:if>
        <s:else>
            <div id="contentWrap">
                <div id="main">
                    <h2>用户注册</h2>
                    <s:form action="register" method="post" name="signup" id="signup">
                        <div>
                            <label  class="label">用户名 </label>
                            <s:textfield name="register.username"  id="name" ></s:textfield>
                        </div>

                        <div>
                            <label class="label">密码</label>
                            <s:password name="register.password"  id="password"></s:password>
                        </div>
                        <div>
                            <label class="label">确认密码</label>
                            <s:password name="confirm_password" id="confirm_password"></s:password>
                        </div>
                        <div>
                            <label  class="label">邮箱</label>
                            <s:textfield name="register.email" id="email"></s:textfield>
                        </div>
                        <div>
                            <s:submit name="submit" id="login" value="注册"></s:submit>
                        </div>
                    </s:form>
                </div>
            </div>
        </s:else>
    </body>
</html>
